package com.cheney.diandireader.server.action;

import java.io.UnsupportedEncodingException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.cheney.diandireader.server.domain.AttachFileCategory;
import com.cheney.diandireader.server.service.FileCategoryService;

/**
 * fileTypeAction
 * @author mayh
 *
 */
@Controller
@RequestMapping("/fileType")
public class FileCategoryAction {
	@Autowired
	private FileCategoryService fileTypeService;
	
	//find all filetype
	@RequestMapping("/list")
	public ModelAndView list(){
		ModelAndView mav = new ModelAndView("filetype/list");  
		List<AttachFileCategory> fileTypeList = fileTypeService.list();
		mav.addObject("list", fileTypeList);
		return mav;
	}
	
	//save filetype
	@RequestMapping("/save")
	public String save(AttachFileCategory attachFileType){
		fileTypeService.save(attachFileType);
		return "redirect:/fileType/list.action";
	}
	
	//save filetype
	@RequestMapping("/delete")
	public String delete(AttachFileCategory attachFileType){
		fileTypeService.delete(attachFileType);
		return "redirect:/fileType/list.action";
	}
	
	//save filetype
	@RequestMapping("/update")
	public String update(AttachFileCategory attachFileType){
		fileTypeService.update(attachFileType);
		return "redirect:/fileType/list.action";
	}
}
